﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Exchange_View.aspx.cs" Inherits="JKF.Web.Points.Point_Exchange_View" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
        <%= RegScript("~/js/jquery.1.5.js")%>
        <%= RegScript("~/js/jquery.nhis.js")%>
        <%= RegScript("~/js/jquery.rchis.js")%>
        <%= RegScript("~/js/jquery-ui-custom.min.js")%>
        <%= RegScript("~/js/css.js")%>
        <%= RegScript("~/js/DatePicker/WdatePicker.js")%>
        <%= RegScript("~/js/Common.js")%>
        <%= RegScript("~/js/Jquery.commonGrid.js")%>
        <script src="../../js/Uppop/tipswindown2.js"  type="text/javascript"></script>

        <link href="../../App_Themes/Theme2/Include.css"   rel="stylesheet" type="text/css" />
          <script type="text/javascript">
              var isView = '<%=IsView%>'; //是否有浏览权限
              var isAdd = '<%=IsAdd%>' == 'True' ? '' : 'none'; //是否具有添加权限
              var isEdit = '<%=IsEdit%>' == 'True' ? '' : 'none'; //是否具有编辑权限
              var isDelete = '<%=IsDelete%>' == 'True' ? '' : 'none'; // 是否具有删除权限

              var AppPath = '<%=AppPath %>';
              var handler = AppPath + '/do/Points/Point_Exchange.do';
              var PageSize = 20;
              var pager = null;
              var shops = <%=Shops%>;
              $(function () {
                  if (isAdd == "none")  //判断权限添加按钮是否显示
                      $("#btnAdd").hide();

                  pager = $('#divPager').pager(AppPath, handler, function () {
                      return { ActionName: 'GetPointExchange', searchItem: $('#dropSearchItem').val(), matchWay: $('#dropMatchWay').val(), keyword: $('#txt_keyword').val(), dateStart: $('#txt_CREATE_START').val(), dateEnd: $('#txt_CREATE_END').val(),ownShop:$.FxNull($("#ownShop").attr("codes"), "") };
                  }, function (data) {
                      var tbody = $('#tb tbody');
                      tbody.empty();
                      if (data && data.Entity && data.Entity.length) {
                          data = data.Entity
                          var tr, td;
                          for (var i = 0; i < data.length; i++) {
                              var item = data[i];
                              tr = $("<tr key=" + item.EXCHANGE_KEY + "></tr>").appendTo(tbody);
                              $('<td></td>').appendTo(tr).html('<input  class="common_btn_edit mr12"  type="button"  style="display:' + isEdit + '" onclick="addExchange(' + "'" + item.EXCHANGE_KEY + "'" + ')" ><input  style="display:' + isDelete + '" type="button" class="common_btn_del mr12"  onclick="deleteExchange(' + "'" + item.EXCHANGE_KEY + "'" + ')">');
                              $('<td></td>').appendTo(tr).text(item.EXCHANGE_NO);
                              $('<td></td>').appendTo(tr).text(item.CARD_NO);
                              $('<td></td>').appendTo(tr).text(item.NAME);
                              $('<td></td>').appendTo(tr).text(item.MOBILE);
                              $('<td></td>').appendTo(tr).text(item.GIFTS);
                              $('<td></td>').appendTo(tr).text(item.DEDUCT_POINT);
                              $('<td></td>').appendTo(tr).text(item.MEMO);
                              $('<td></td>').appendTo(tr).text(item.ACCOUNT);
                              $('<td></td>').appendTo(tr).text(item.DATE_EXCHANGE);
                          }
                      } else {
                          tbody.html('<tr><td id="emptyTr" colspan="9" style="text-align: center">没有数据!</td></tr>');

                      }
                      var tbHeight = $(window).height() - $(".common_search").height() - $("#divPager").height() - 38;
                      tbHeight = tbHeight < 300 ? 300 : tbHeight;
                      $("#tb").H8_Grid($("#divPager"), tbHeight);
                  }, PageSize, true);

                  $('#btn_search').click(function () {
                      pager.option.pageIndex = 1;
                      pager.getPegerData();
                      return false;
                  });

                  $("#ownShop").MgrShopSelect(AppPath, shops);
              });

              //弹出层
              function addExchange(id) {
                  window.parent.pop("兑换礼品", '<%= ResolveUrl("~/Points/Exchange_Add.aspx?exchangeKey=") %>' + id, 870, 560, updateList)
              };

              function deleteExchange(exchangeKey) {
                  if (!confirm("确认删除吗?"))
                      return false;

                  $.post(handler, { ActionName: "DeleteExchange", exchangeKey: exchangeKey },
                   function (rslt) {
                       if (rslt.MessageCode == "Ok") {
                           $("tr[key='" + exchangeKey + "']").remove();
                           reduceCount(); //删除成功之后减少记录总条数
                           alert("删除成功."); return;
                       }
                   }
                , "json");
              }

              //回调函数，弹出层保存成功之后执行，更新列表中数据，或往列表中添加新录的数据
              function updateList(obj, id) {
                  if ($.FxNull(id, "").length > 0) {//修改
                      $("#tb tbody tr[key='" + id + "']").html($(obj).html());

                  } else {//添加
                      if ($('#emptyTr')) { // 如果存在的话
                          $('#emptyTr').remove(); // 当添加成功的话，移除此行
                      }
                      addCount(); //添加成功之后更新记录总条数
                      $('#tb tbody').prepend(obj);

                  }
              }
      </script>
</head>
<body>
      <div class="warrper_body">  
         <div class="index" style=" overflow:hidden">
            <div class="common_search">
                 <div class="l_h45">  
                    查询项：
                      <select id="dropSearchItem">
                           <option selected value="CARD_NO">卡号</option>
                           <option value="NAME">姓名</option>
                           <option value="MOBILE">手机号</option>
                           <option value="EXCHANGE_NO">单号</option>
                           <option value="GIFTS">兑换礼品</option>
                           <option value="DEDUCT_POINT">消耗积分</option>
                           <option value="MEMO">备注</option>
                           <option value="REAL_NAME">操作人</option>
                     </select>
                     <select id="dropMatchWay" style=" width:35px">
                         <option selected value="=">=</option>
                         <option value="包含">包含</option>
                     </select>
                     <input type="text" id="txt_keyword" value="" />
                    兑换日期：<input id="txt_CREATE_START" style="width: 100px" type="text" onfocus="WdatePicker()" />
                    至<input id="txt_CREATE_END" style="width: 100px" type="text" onfocus="WdatePicker()" />
                    <span class="mr30 mb20">所属店铺：
                        <input type="button" id="ownShop" class="common_btn_gaoji115" />
                    </span>
                    <span class="mr30"><input  id="btn_search" type="button"  class="common_btn_search"/></span>
                    <input id="btnAdd" type="button" class="common_btn_add2" value=" "  onclick="addExchange('')"/>
                 </div>
            </div>
            <div class="l_h7"></div>
           
            <div class="index_table">
                <table id="tb" class="common_table">
                    <thead>
                        <tr>
                            <th width="100px" orderaction="false">操作</th>
                            <th width="130px" ordertype="string">单号</th>
                            <th width="80px" ordertype="string">卡号</th>
                            <th width="100px" ordertype="string">姓名</th>
                            <th width="100px" ordertype="string">手机号</th>
                            <th width="250px" ordertype="string">兑换礼品</th>
                            <th width="60px" ordertype="string">扣除积分</th>
                            <th width="120px" ordertype="string">备注</th>
                            <th width="80px" ordertype="string">操作员</th>
                            <th width="150px" ordertype="string">兑换日期</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td colspan="10" style="text-align: center">点击搜索查看数据</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class="page" id="divPager"></div>      
        </div>
     </div> 
</body>
</html>
